-- skill_bonus
-- create by shuzy
-- 技能: 通用奖励


return {
    apply = function(source, target, skillId, round, para, extra)
        -- 奖励
        BonusM.doBonus(para, "skill_bonus");
        -- 奖励事件
        EventMgr.fire(event.SKILL_BONUS, { ["bonus"] = para});

        return para[3];
    end,

    parse = function(desc)
        local arr = string.explode(desc, ",");
        if 1 == tonumber(arr[1]) then
            return { tonumber(arr[1]), tonumber(arr[2]), tonumber(arr[3]), };
        else
            return { tonumber(arr[1]), arr[2], tonumber(arr[3]), };
        end
    end,

    -- 解析技能描述
    parseDesc = function(source, skillId, desc, para)
        -- 奖励物品
        if para[1] == 1 then
            local item = ItemM.query(para[2], "name") or "";
            desc = string.gsub(desc, "{item}", item, 1);
        end
        -- 奖励属性
        if para[1] == 2 then
            local attrib = FieldsM.getFieldName(para[2]) or "";
            desc = string.gsub(desc, "{attrib}", attrib, 1);
        end

        -- 数量
        local num = para[3];
        desc = string.gsub(desc, "{num}", num, 1);

        return desc;
    end,
}
